/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2024-06-15
 * Time: 20:03
 */
class Solution5 {

    int sum;
    int path;
    public int subsetXORSum(int[] nums) {
        dfs(nums,0);
        return sum;
    }

    void dfs(int[] nums, int pos) {
        sum += path;

        for(int i = pos; i < nums.length; i++) {
            path ^= nums[i];
            dfs(nums,i+1);
            //恢复现场
            path ^= nums[i];
        }
    }
}
